<?php
namespace gzapi\common\business;
use gzapi\common\model\GzHiseServiceProTestModel;
use think\Controller;
use cmf\controller\PublicController;
class DeBug  extends PublicController{
        /*保存调试信息*/
        public static function  saveData($userData,$debugData){
            $field=['azd_id','ts_dw','ts_ry','ts_fwgcs','ts_ifwp','ts_jsfy'];
             $debugArr=[];
            foreach($debugData as $k=>$v){
                 if(in_array($k,$field)){
                         $debugArr[$k]=$v;
                }
            }
            $debugArr['ts_zt']=0;   //调试状态
            $debugArr['ts_code']=date('Ymd').time().rand(0000,9999);  //自定义生成  调试编码
            $debugArr['ts_jsbz']='';   //结算标准
            $debugArr['ts_bg']='';   //调试报告
            $debugArr['created_by']=$userData['mobilphone'];  //创建人
            $debugArr['created_date']=date('Y-m-d');  //创建时间
            $debugArr['last_upd_date']=date('Y-m-d');   //修改时间
            $res=GzHiseServiceProTestModel::saveProTest($debugArr);
            return $res;
        }
        /*获取调试详细信息*/
        public static function getDataInfo($data){
           $res= GzHiseServiceProTestModel::proTestInfo($data);
           return $res;
        }
        //修改调试消息
        public static function editData($userData,$data){
    $field=['azd_id','ts_dw','ts_ry','ts_fwgcs','ts_ifwp','ts_jsfy'];
    $debugArr=[];
            foreach($data as  $k=>$v){
                if(in_array($k,$field)){
                    $debugArr[$k]=$v;
                }
             }
            $debugArr['ts_zt']=1;   //调试状态
            $debugArr['ts_code']=1;  //自定义生成  调试编码
            $debugArr['ts_jsbz']='';   //结算标准
            $debugArr['ts_bg']='';   //调试报告
            $debugArr['created_by']=$userData['mobilephone'];  //创建人
            $debugArr['created_date']=date('Y-m-d');  //创建时间
            $debugArr['last_upd_date']=date('Y-m-d');   //修改时间
            //查询是否已存在调试单
            $validate['azd_id']=$debugArr['azd_id'];
            if(!GzHiseServiceProTestModel::proTestInfo($validate)){
                $this->error('请先创建该调试单');
            }
            $res=GzHiseServiceProTestModel::editProTest($validate,$debugArr);
            return $res;
        }
     public static function searchData($data){
            $where=[];
            foreach($data as $k=>$v){
                 $where[$k]=$v;
            }
         $res= GzHiseServiceProTestModel::proTestInfo($where);
         return $res;
     }
}